<?php
/**
 * Copyright © 2013-2017 Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

// @codingStandardsIgnoreFile

?>
<?php
/** @var $block \Magento\Weee\Block\Renderer\Weee\Tax */
$data = ['fptAttribute' => [
    'region' => $this->helper('Magento\Framework\Json\Helper\Data')->jsonDecode(
        $this->helper('Magento\Directory\Helper\Data')->getRegionJson()
    ),
    'itemsData' => $block->getValues(),
    'bundlePriceType' => '#price_type',
]];
?>
<div id="attribute-<?php echo $block->getElement()->getHtmlId(); ?>-container" class="field"
     data-attribute-code="<?php echo $block->getElement()->getHtmlId(); ?>"
     data-mage-init="<?=$block->escapeHtml($this->helper('Magento\Framework\Json\Helper\Data')->jsonEncode($data))?>">
    <label class="label"><span><?php /* @escapeNotVerified */ echo $block->getElement()->getLabel() ?></span></label>

    <div class="control">
        <table class="data-table">
            <thead>
                <tr>
                    <th class="col-website" <?php if (!$block->isMultiWebsites()): ?>style="display: none;"<?php endif; ?>><?php /* @escapeNotVerified */ echo __('Website'); ?></th>
                    <th class="col-country required"><?php /* @escapeNotVerified */ echo __('Country/State'); ?></th>
                    <th class="col-tax required"><?php /* @escapeNotVerified */ echo __('Tax'); ?></th>
                    <th class="col-action"><?php /* @escapeNotVerified */ echo __('Action'); ?></th>
                </tr>
            </thead>
            <tfoot>
                <tr>
                    <td colspan="4" class="col-actions-add"><?php echo $block->getAddButtonHtml(); ?></td>
                </tr>
            </tfoot>
            <tbody data-role="fpt-item-container" class="fpt-item-container">
            </tbody>
        </table>
        <!--
            Hidden field below with attribute code id is necessary for jQuery validation plugin.
            Validation message will be displayed after this field.
        -->
        <input type="hidden" name="<?php echo $block->getElement()->getHtmlId(); ?>" id="<?php echo $block->getElement()->getHtmlId(); ?>" disabled="disabled">
    </div>

    <script data-role="row-template" type="text/x-magento-template">
        <tr id="<?php echo $block->getElement()->getHtmlId() ?>_weee_tax_row_<%- data.index %>" data-role="fpt-item-row">
            <td class="col-website" <?php if (!$block->isMultiWebsites()): ?>style="display: none"<?php endif; ?>>
                <select id="<?php /* @escapeNotVerified */ echo $block->getElement()->getName() ?>_weee_tax_row_<%- data.index %>_website"
                        name="<?php /* @escapeNotVerified */ echo $block->getElement()->getName() ?>[<%- data.index %>][website_id]"
                        class="<?php /* @escapeNotVerified */ echo $block->getElement()->getClass() ?> website required-entry" data-role="select-website">
                    <?php foreach ($block->getWebsites() as $_websiteId => $_info): ?>
                    <option value="<?php /* @escapeNotVerified */ echo $_websiteId ?>"><?php /* @escapeNotVerified */ echo $_info['name'] ?><?php if (!empty($_info['currency'])): ?>[<?php /* @escapeNotVerified */ echo $_info['currency'] ?>]<?php endif; ?></option>
                    <?php endforeach ?>
                </select>
            </td>
            <td class="col-country">
                <select id="<?php /* @escapeNotVerified */ echo $block->getElement()->getName() ?>_weee_tax_row_<%- data.index %>_country"
                        name="<?php /* @escapeNotVerified */ echo $block->getElement()->getName() ?>[<%- data.index %>][country]"
                        class="<?php /* @escapeNotVerified */ echo $block->getElement()->getClass() ?> country required-entry" data-role="select-country">
                    <?php foreach ($block->getCountries() as $_country): ?>
                    <option value="<?php /* @escapeNotVerified */ echo $_country['value'] ?>"><?php /* @escapeNotVerified */ echo htmlspecialchars($_country['label']) ?></option>
                    <?php endforeach ?>
                </select>
                <select id="<?php /* @escapeNotVerified */ echo $block->getElement()->getName() ?>_weee_tax_row_<%- data.index %>_state"
                        name="<?php /* @escapeNotVerified */ echo $block->getElement()->getName() ?>[<%- data.index %>][state]"
                        class="<?php /* @escapeNotVerified */ echo $block->getElement()->getClass() ?> state" disabled="" data-role="select-state">
                    <option value="0">*</option>
                </select>
            </td>
            <td class="col-tax">
                <input name="<?php /* @escapeNotVerified */ echo $block->getElement()->getName() ?>[<%- data.index %>][price]"
                       class="<?php /* @escapeNotVerified */ echo $block->getElement()->getClass() ?> required-entry validate-greater-than-zero"
                       type="text" value="<%- data.value %>"/>
            </td>
            <td class="col-action">
                <input name="<?php /* @escapeNotVerified */ echo $block->getElement()->getName() ?>[<%- data.index %>][delete]" class="delete" type="hidden" value="" data-role="delete-fpt-item"/>
                <?php echo $block->getChildHtml('delete_button') ?>
            </td>
        </tr>
    </script>
</div>
